package com.sntk.organauthomanager.infrastructure.db.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.util.Date;

/**
 * @ClassName: ResourceEntity
 * @author: wgchao
 * @createTime: 2020/7/21 4:17 PM
 * @Description: TODO
 */
@Table(name = "sys_organ_resource_info", uniqueConstraints = @UniqueConstraint(columnNames = {"mark"}))
@org.hibernate.annotations.Table(appliesTo = "sys_organ_resource_info", comment = "资源信息")
@Entity
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ResourceEntity {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Long id;

    //资源标识
    @Column(name = "mark", length = 100, columnDefinition="varchar(50) COMMENT '资源标识'", nullable = false)
    private String mark;

    //资源名称
    @Column(name = "name", length = 100, columnDefinition="varchar(100) COMMENT '资源名称'", nullable = false)
    private String name;

    //资源类型
    @Column(name = "resource_type", columnDefinition="integer COMMENT '资源类型 1:菜单 2：按钮 3：其他'", nullable = false)
    private Integer resourceType;

    //资源深度 1代表一级
    @Column(name = "depth", columnDefinition="integer COMMENT '资源深度 1代表一级'", nullable = false)
    private Integer depth;

    @Column(name = "parent_resource", length = 100, columnDefinition="varchar(50) COMMENT '父资源标识'")
    private String parentResource;

    @Column(name = "disabled", columnDefinition="bit(1) COMMENT '禁用标识'", nullable = false)
    private Boolean disabled;

    @Column(name = "del", nullable = false)
    private Boolean del;

    @Column(name = "create_time")
    private Date createTime;

    @Column(name = "creator", length = 50)
    private String creator;

    @Column(name = "last_update_time")
    private Date lastUpdateTime;

    @Column(name = "last_updator", length = 50)
    private String lastUpdator;


    //乐观锁 ObjectOptimisticLockingFailureException异常
    @Version
    private Long version;
}
